﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Controls_Register : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        User menber = new User();
        menber.User_Name = this.txttentaikhoan.Text;
        menber.User_Email = this.txtemail.Text;
        menber.User_Address = this.txtdiachi.Text;
        menber.User_Password = this.txtpass.Text;
        if (rbtnnam.Checked == true)
        {
            menber.User_Sex = rbtnnam.Checked;
        }
        else if (rbtnnam.Checked != true)
        {
            menber.User_Sex = rbtnnu.Checked;
        }
        menber.User_Phone = this.txtdienthoai.Text;
        menber.User_Company = this.txtcongty.Text;
        menber.User_Status = true;
        menber.User_IsAdmin = false;
        menber.User_Type = 0; // mac dinh la nguoi kahch
        menber.User_Nick = this.txtnick.Text;
        if (!User_Session.Insert_User(menber))
        {
            lbErr.Text = "User đã tồn tại bấm vào đây dể lấy lại mật khẩu <a href=''> click </a>";
        }
        else
        {
            string id = String.Empty;
            if (User_Session.IsExitUser(menber.User_Name.Trim(), menber.User_Password.Trim(), ref id))
            {
                Session["User_Type"] = menber.User_Type;
                Session["User_Name"] = menber.User_Name;
                Session["User_ID"] = id;
                Response.Redirect("Default.aspx");
            }
        }
         
        
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
